#include "JNIClass.h"
#include "cocos2d.h"

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include "platform/android/jni/JniHelper.h"
#include <jni.h>

const char* AppActivityClassName = "softtech/apps/KillCockroachs/KillCockroachs";

void JNIClass::vibrate(long time){
	cocos2d:: JniMethodInfo methodInfo;
	if(!cocos2d::JniHelper::getStaticMethodInfo(methodInfo, AppActivityClassName, "vibrate","(J)V"))
	{
		return;
	}
	methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, time);
	methodInfo.env->DeleteLocalRef(methodInfo.classID);
}

void JNIClass::cancelVibrate(){
	cocos2d:: JniMethodInfo methodInfo;
	if(!cocos2d::JniHelper::getStaticMethodInfo(methodInfo, AppActivityClassName, "cancelVibrate","(J)V"))
	{
		return;
	}
	methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
	methodInfo.env->DeleteLocalRef(methodInfo.classID);
}

void JNIClass::rateApp(){

	cocos2d::JniMethodInfo methodInfo1;
	if (cocos2d::JniHelper::getStaticMethodInfo(methodInfo1, AppActivityClassName, "rateApp", "()V"))
	{
		methodInfo1.env->CallStaticVoidMethod(methodInfo1.classID, methodInfo1.methodID);
		methodInfo1.env->DeleteLocalRef(methodInfo1.classID);
	}
}

void JNIClass::aboutUs(){
	cocos2d::JniMethodInfo methodInfo;
	if (cocos2d::JniHelper::getStaticMethodInfo(methodInfo, AppActivityClassName, "aboutUs", "()V"))
	{
		methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
		methodInfo.env->DeleteLocalRef(methodInfo.classID);
	}
}
#endif
